<?php

class Kd_Data_Table_Column_Guid extends Kd_Data_Table_Column_Base {

    private $_insertValue = '';

    public function __construct() {
        parent::__construct();
        $this->setDefaultValue(0);
    }

    public function getInsertValue(){
        return $this->_insertValue;
    }

    public function convertToDb($value) {
        if(is_null($value) || empty($value)){
            $this->_insertValue = Kd_Util_Random::generateUnid('column_');
            return $this->_insertValue;
        }
        return $value;
    }

    public function validate($value) {
        return true;
    }

    public function getColumnType() {
        return 'guid';
    }

    public function getParameterName() {
        return ':' . $this->getColumnName() . ':s';
    }

}